# -*- coding: utf-8 -*-
# @Time    : 2023/2/7 16:25
# @Author  : kali
from threading import Thread

from flask import request

from api import ApiResource
from service.tags_service import get_tags_data
from spider import tags_spider


class Tags(ApiResource):

    def get(self):
        req_data = request.args.to_dict()
        data, count = get_tags_data(req_data)
        return self.success(data=data, count=count)


class TagsSpider(ApiResource):

    def get(self):
        # 使用线程启动
        # thread = Thread(target=tags_spider)
        # thread.start()
        tags_spider()
        return self.success()
